//
//  LogOutCell.m
//  jiaKaoZhuShou
//
//  Created by 金艺社 on 2018/5/21.
//  Copyright © 2018年 金艺社. All rights reserved.
//

#import "LogOutCell.h"
#import "logInVCViewController.h"
#import "BaseNavigationConler.h"
@implementation LogOutCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.logOut_btn.layer.masksToBounds = YES;
    self.logOut_btn.layer.cornerRadius = 22;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)logOutClick:(id)sender {
    [self LogOutRequest];
}

#pragma mark --- 退出登录
- (void)LogOutRequest {
    NSDictionary *dic = @{
                          @"token" : USERTOKEN
                          };
    [networkManger PostHttpDataWithUrlStr:[[apiManger shareApiManger] logOut] Dic:dic SuccessBlock:^(id responseObject) {
        
        if ([responseObject[@"rmg"] isEqualToString:@"退出成功"]) {
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            [user removeObjectForKey:@"token"];
            [user removeObjectForKey:@"password"];
            [user removeObjectForKey:@"userName"];
            [user synchronize];
            [self pushRootVC];
        }else {
            [MBProgressHUD gk_toastShowMessage:responseObject[@"rmg"]];
        }
    } FailureBlock:^(id error) {
        [MBProgressHUD gk_toastShowMessage:@"数据获取失败"];
    }];
}
- (void)pushRootVC {
    BaseNavigationConler * navc = [[BaseNavigationConler alloc] initWithRootViewController:[logInVCViewController new]];
    self.window.rootViewController = navc;
}
@end
